﻿using System;
using UnityEngine;

public class SSCAdsUnityAdapter
{

	// java method names

//	private string _methodPreloadAll = "preloadAll";
//	private string _methodPreloadAd = "preloadAd";
	private string _methodShowAd = "showAd";
	private string _methodRemoveAd = "removeAd";
//	private string _methodSetHidden = "setHidden";
	private string _methodPosition = "setBannerPosition";
	private string _methodSetGameObjName = "setGameObjName";
//	private string _methodGetAdId = "getAdid";
	private string _methodGetBannerWidth = "getAdBannerWidth";
	private string _methodGetBannerHeight = "getAdBannerHeight";

	private static SSCAdsUnityAdapter _instance;
	private string _gameObjName;



	private SSCAdsUnityAdapter ()
	{
	}

	public static SSCAdsUnityAdapter getInstance ()
	{
		if (_instance == null) {
			_instance = new SSCAdsUnityAdapter ();
		}
		return _instance;
	}
//	public void preloadAll ()
//	{
//		AndroidHelper.getAdsManagerAndroidObject().Call (_methodPreloadAll);
//	}
//
//	public void preloadAd (int adType)
//	{
//		Debug.Log ("preload ad -----------");
//		AndroidHelper.getAdsManagerAndroidObject().Call (_methodPreloadAd, adType);
//	}

	public bool showAd (int adType)
	{

//		AndroidHelper.getAdsManagerAndroidObject().Call (_methodShowAd, adType);
		return AndroidHelper.getAdsManagerAndroidObject().Call<bool> (_methodShowAd, adType);

	}

	public void removeAd (int adType)
	{
		AndroidHelper.getAdsManagerAndroidObject().Call (_methodRemoveAd, adType);
	}

//	public void setHidden (int adType, bool bHidden)
//	{
////		int hidden = bHidden ? 1 : 0;
////		AndroidHelper.getAdsManagerAndroidObject().Call (_methodSetHidden, adType, hidden);
//		AndroidHelper.getAdsManagerAndroidObject().Call (_methodSetHidden, adType, bHidden);
//
//
//	}

	public void setPosition (int adType, int bannerPosition)
	{
		AndroidHelper.getAdsManagerAndroidObject().Call (_methodPosition, adType, bannerPosition);

	}

	public void setGameObjName (string name)
	{
		AndroidHelper.getAdsManagerAndroidObject().Call (_methodSetGameObjName, name);
	}

//	public string getAdid (int adType)
//	{
//		string adid =  AndroidHelper.getAdsManagerAndroidObject().Call <string> (_methodGetAdId, adType);
//		Debug.Log ("Ad id ----" + adid);
//		return adid;
//
//	}
	public Vector2 getBannerSize (int adType)
	{
		int width =  AndroidHelper.getAdsManagerAndroidObject().Call <int> (_methodGetBannerWidth, adType);
		int height =  AndroidHelper.getAdsManagerAndroidObject().Call <int> (_methodGetBannerHeight, adType);

		return new Vector2(width ,height );

	}
		
}


